package com.kcn.jsonaction;

import com.kcn.cus.Customer;
import com.kcn.dbservices.CurdService;
import com.opensymphony.xwork2.ActionSupport;

public class EditAction extends ActionSupport {
	private String contactor2;
	private String cusname;
	private String cusaddress;
	private String contactor1;
	private String cusnumber;
	private String faxnumber;
	private String zone;
	private String oper;
	private CurdService curds;
	private String id;

	public String execute() {
		// TODO Auto-generated method stub
		curds = new CurdService();
		System.out.println(this.getContactor1() + this.getCusaddress()
				+ this.getCusname() + this.getContactor2());
		Customer cus = new Customer();
		cus.setContactor1(contactor1);
		cus.setContactor2(contactor2);
		cus.setCusaddress(cusaddress);
		cus.setCusname(cusname);
		cus.setFaxnumber(faxnumber);
		cus.setCusnumber(cusnumber);
		cus.setZone(zone);
		if (this.getOper().equals("add")) {
			curds.save(cus);
		} else if (this.getOper().equals("edit")) {
			cus.setId(Integer.parseInt(id));
			curds.update(cus);
		} else if (this.getOper().equals("del")) {
			cus.setId(Integer.parseInt(id));
			curds.delete(cus);
		} else
			return ERROR;
		return SUCCESS;
	}

	public String getContactor2() {
		return contactor2;
	}

	public void setContactor2(String contactor2) {
		this.contactor2 = contactor2;
	}

	public String getCusaddress() {
		return cusaddress;
	}

	public void setCusaddress(String cusaddress) {
		this.cusaddress = cusaddress;
	}

	public String getContactor1() {
		return contactor1;
	}

	public void setContactor1(String contactor1) {
		this.contactor1 = contactor1;
	}

	public String getOper() {
		return oper;
	}

	public void setOper(String oper) {
		this.oper = oper;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCusname() {
		return cusname;
	}

	public void setCusname(String cusname) {
		this.cusname = cusname;
	}

	public String getCusnumber() {
		return cusnumber;
	}

	public void setCusnumber(String cusnumber) {
		this.cusnumber = cusnumber;
	}

	public String getFaxnumber() {
		return faxnumber;
	}

	public void setFaxnumber(String faxnumber) {
		this.faxnumber = faxnumber;
	}

	public String getZone() {
		return zone;
	}

	public void setZone(String zone) {
		this.zone = zone;
	}
}
